package com.hopedove.quanlitycheck.domain.net;

import com.hopedove.net.domain.JsonParamRequest;
import com.hopedove.quanlitycheck.entity.FgpzEntity;
import com.hopedove.utils.CommonUtil;

import org.json.JSONObject;

import java.util.List;
import java.util.Map;

public class SaveInfo extends JsonParamRequest {

    public SaveInfo(String userBean, FgpzEntity oldFgpzEntity, FgpzEntity fgpzEntity) {

        try {
            JSONObject userbeanObject = new JSONObject(userBean);
            putParam("userBean", userbeanObject);
            JSONObject fgpzObject = new JSONObject();
            fgpzObject.put("CLOTHTKTNO", fgpzEntity.getCLOTHTKTNO());//这两个值必须要有，不管变不变
            fgpzObject.put("QUALITYID", fgpzEntity.getQUALITYID());//这两个值必须要有，不管变不变
            try {
                List<Map<String, Object>> mapList = CommonUtil.compareTwoClass(oldFgpzEntity, fgpzEntity);
                for (Map<String, Object> map :
                        mapList) {
                    fgpzObject.put(map.get("name").toString(), map.get("new").toString());
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            putParam("Fgpzspzljcb", fgpzObject);
        } catch (Exception e) {
            // ignore
        }
    }

    @Override
    protected String getMethod() {
        return "saveFgpzspzljcb";
    }
}
